package com.fuego.creditsystemcommodity.controller;

import com.fuego.creditsystemcommodity.service.IRoomOrderService;
import jakarta.annotation.Resource;
import org.example.dto.Result;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/room-order")
public class RoomOrderController {
    @Resource
    private IRoomOrderService roomOrderService;

    @PostMapping("roomInfo/{id}")
    public Result roomInfo(
            @PathVariable("id") Long roomId,
            @RequestParam("userId") Long userId,
            @RequestParam("startDate") LocalDateTime startDate,
            @RequestParam("endDate") LocalDateTime endDate,
            @RequestParam("amount") Integer amount) {
        return roomOrderService.roomInfo(roomId, userId, startDate, endDate, amount);
    }

    @GetMapping("/list/allOrder")
    public Result queryAllOrder(@RequestParam("userId") Long userId) {
        return roomOrderService.queryAllOrders(userId);
    }

    @PostMapping("/refund")
    public Result refund(@RequestParam("orderId") Long orderId) {
        return roomOrderService.refund(orderId);
    }
}